Python Function Testing

This notebook is for testing all the Python functions. Each cell is a data source class; feel free to experiment to your heart's content.


In [2]:
import augur

# import everything that githubapi.py imports so we can just copy and paste our function later
augur_app = augur.Application('../augur.config.json')

In [26]:
import pandas as pd
import sqlalchemy as s
import numpy as np
import re
from augur import logger
from augur.util import annotate

ghtorrent = augur_app.ghtorrent()
owner='rails'
repo='rails'

# ghtorrent.closed_issues(owner, repo)
# ghtorrent.code_commits(owner, repo)
# ghtorrent.code_review_iteration(owner, repo)
# ghtorrent.contribution_acceptance(owner, repo)
# ghtorrent.contributing_github_organizations(owner, repo)
# ghtorrent.first_response_to_issue_duration(owner, repo)
# ghtorrent.forks(owner, repo)
# ghtorrent.maintainer_response_to_merge_request_duration(owner, repo)
# ghtorrent.new_contributing_github_organizations(owner, repo)
# ghtorrent.open_issues(owner, repo)
# ghtorrent.pull_request_comments(owner, repo)
# ghtorrent.pull_requests_open(owner, repo)
# ghtorrent.issue_comments(owner, repo)
# ghtorrent.watchers(owner, repo)
# ghtorrent.commits100(owner, repo)
# ghtorrent.commit_comments(owner, repo)
# ghtorrent.committer_locations(owner, repo)
# ghtorrent.total_committers(owner, repo)
# ghtorrent.issue_activity(owner, repo)
# ghtorrent.pull_request_acceptance_rate(owner, repo)
# ghtorrent.community_age(owner, repo)
# ghtorrent.community_engagement(owner, repo)
# ghtorrent.contributors(owner, repo)
# ghtorrent.contributions(owner, repo)
# ghtorrent.classify_contributors(owner, repo)
# ghtorrent.project_age(owner, repo)
# ghtorrent.fakes(owner, repo)
# ghtorrent.ghtorrent_range(owner, repo)

In [ ]:
import pandas as pd
import sqlalchemy as s
import numpy as np
import re
from augur import logger

ghtorrentplus = augur_app.ghtorrentplus()
owner='rails'
repo='rails'

# ghtorrentplus.closed_issue_resolution_duration(owner, repo)

In [23]:
import sys
import pandas as pd
if sys.version_info > (3, 0):
    import urllib.parse as url
else:
    import urllib as url

publicwww = augur_app.publicwww()
owner='rails'
repo='rails'

# publicwww.linking_websites(owner, repo)

In [28]:
import os
import shutil
import re
import json
import datetime
import pandas as pd
import git
from lockfile import LockFile, AlreadyLocked
from augur.util import logger, get_cache

git = augur_app.git()

# git.get_repo("https://github.com/rails/rails")
# git.update()
# git.downloaded_repos()
# git.lines_changed_minus_whitespace("https://github.com/rails/rails")
# git.changes_by_author("https://github.com/rails/rails")


---------------------------------------------------------------------------
NoSuchPathError                           Traceback (most recent call last)
<ipython-input-28-45c4dcdad33f> in <module>()
     14 # git.update()
     15 # git.downloaded_repos()
---> 16 git.lines_changed_minus_whitespace("https://github.com/rails/rails")
     17 # git.changes_by_author("https://github.com/rails/rails")

~/Documents/Code/augur/augur/git.py in lines_changed_minus_whitespace(self, repo_url, from_commit, df, rebuild_cache)
    209                                 data['deletions'] = deletions
    210                                 frames.append(pd.DataFrame(data, index=['hash']))
--> 211 
    212 
    213             if len(frames):

~/anaconda3/lib/python3.6/site-packages/beaker/cache.py in get(self, key, **kw)
    320     def get(self, key, **kw):
    321         """Retrieve a cached value from the container"""
--> 322         return self._get_value(key, **kw).get_value()
    323     get_value = get
    324 

~/anaconda3/lib/python3.6/site-packages/beaker/container.py in get_value(self)
    378 
    379             debug("get_value creating new value")
--> 380             v = self.createfunc()
    381             self.set_value(v)
    382             return v

~/Documents/Code/augur/augur/git.py in heavy_lifting()
    162 
    163     def lines_changed_minus_whitespace(self, repo_url, from_commit=None, df=None, rebuild_cache=False):
--> 164         """
    165         Makes sure the storageFolder contains updated versions of all the repos
    166         """

~/Documents/Code/augur/augur/git.py in git(self, is_updater)
     74         else:
     75             if self.__git is None or is_updater:
---> 76                 self.__git = git.Repo(self.path)
     77             return self.__git
     78 

~/anaconda3/lib/python3.6/site-packages/git/repo/base.py in __init__(self, path, odbt, search_parent_directories, expand_vars)
    122         epath = expand_path(epath, expand_vars)
    123         if not os.path.exists(epath):
--> 124             raise NoSuchPathError(epath)
    125 
    126         ## Walk up the path to find the `.git` dir.

NoSuchPathError: /Users/carterlandis/Documents/Code/augur/runtime/git_repos/repos/rails/repo

In [4]:
from augur.localcsv import LocalCSV
import json
import re
from dateutil.parser import parse
import pandas as pd
import github
import numpy as np
import datetime
import requests
from augur import logger

github = augur_app.githubapi()
owner='rails'
repo='rails'

github.lines_of_code_changed(owner, repo)
# github.bus_factor(owner, repo)
# github.major_tags(owner, repo)
# github.tags(owner, repo)
# github.contributors_gender(owner, repo)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-e86e635d5d49> in <module>()
     43         # return the dataframe
     44         return df
---> 45 lines_of_code_changed(owner, repo)

<ipython-input-4-e86e635d5d49> in lines_of_code_changed(self, owner, repo)
     32         # see <project_root>/augur/githubapi.py for examples using the GraphQL API
     33         url = "https://api.github.com/repos/{}/{}/stats/code_frequency".format(owner, repo)
---> 34         json = requests.get(url, auth=('user', self.GITHUB_API_KEY)).json()
     35         # get our data into a dataframe
     36         df = pd.DataFrame(json, columns=['date', 'additions', 'deletions'])

AttributeError: 'str' object has no attribute 'GITHUB_API_KEY'

In [ ]:
import requests
import pandas as pd
import numpy as np
from bs4 import BeautifulSoup
from augur import logger

librariesio = augur_app.librariesio()
owner='rails'
repo='rails'

# librariesio.dependencies(owner, repo)
# librariesio.dependency_stats(owner, repo)
# librariesio.dependents(owner, repo)

In [ ]:
import json
import pandas as pd
import requests
import datetime
import base64
from augur import logger

downloads = augur_app.downloads()
owner='rails'
repo='rails'

# downloads.downloads(owner, repo)
# downloads.ruby_downloads(owner)
# downloads.npm_downloads(owner, repo)

In [ ]:
import pandas as pd
import tldextract
from urllib.parse import urlparse
from .util import get_data_path

localcsv = augur_app.localcsv()
owner='rails'
repo='rails'

localcsv.classify_emails(self, email_series)

In [ ]: